import { injectable, inject } from "inversify";
import { PrismaDB } from "../../db";

@injectable()
export class UserService {
  constructor(@inject(PrismaDB) private prismaDB: PrismaDB) {}

  /**
   * 获取所有用户列表
   */
  public async findList() {
    return await this.prismaDB.prisma.user.findMany();
  }

  /**
   * 获取指定用户信息
   */
  public async findById(id: number) {
    return await this.prismaDB.prisma.user.findUnique({
      where: {
        id,
      },
    });
  }

  /**
   * 创建用户
   */
  public async create(user) {
    return await this.prismaDB.prisma.user.create({
      data: user,
    });
  }
}
